home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / Drag.lisp < prev    next >
Encoding:
Text File  |  1994-09-12  |  14.2 KB  |  386 lines  |  [TEXT/CCL2]

  1.  
  2. (in-package :TRAPS)             ; 
  3. ;     File:        Drag.p
  4. ;     Contains:    External Interface to Drag Manager
  5. ;     Copyright:    © 1992-1993 by Apple Computer, Inc., all rights reserved.
  6.  
  7. ; $IFC UNDEFINED UsingIncludes
  8. ; $SETC UsingIncludes := 0
  9. ; $ENDC
  10.  
  11. ; $IFC NOT UsingIncludes
  12.  
  13. ; $ENDC
  14.  
  15. ; $IFC UNDEFINED UsingDrag
  16. ; $SETC UsingDrag := 1
  17.  
  18. ; $I+
  19. ; $SETC DragIncludes := UsingIncludes
  20. ; $SETC UsingIncludes := 1
  21. ; $IFC UNDEFINED UsingAppleEvents
  22.  
  23. (require-interface 'APPLEEVENTS); $I $$Shell(PInterfaces)AppleEvents.p
  24. ; $ENDC
  25. ; $IFC UNDEFINED UsingTextEdit
  26.  
  27. (require-interface 'TEXTEDIT)   ; $I $$Shell(PInterfaces)TextEdit.p
  28. ; $ENDC
  29. ; $SETC UsingIncludes := DragIncludes
  30.  
  31. ;  Gestalt Selector and Response Constants (will move to GestaltEqu.p) 
  32.  
  33. (defconstant $gestaltDragMgrAttr :|drag|);  Drag Manager attributes 
  34. (defconstant $gestaltDragMgrPresent 0);  Drag Manager is present 
  35.  
  36. (defconstant $gestaltTEAttr :|teat|);  TextEdit attributes 
  37. (defconstant $gestaltTEHasGetHiliteRgn 0);  TextEdit has TEGetHiliteRgn 
  38.  
  39. ;  Flavor Flags 
  40.  
  41. (defconstant $flavorSenderOnly #X1);  flavor is available to sender only 
  42. (defconstant $flavorSenderTranslated #X2);  flavor is translated by sender 
  43. (defconstant $flavorNotSaved #X4);  flavor should not be saved 
  44. (defconstant $flavorSystemTranslated #X100);  flavor is translated by system 
  45.  
  46. (def-mactype :FLAVORFLAGS (find-mactype :SIGNED-LONG))
  47.  
  48. ;  Drag Attributes 
  49.  
  50. (defconstant $dragHasLeftSenderWindow #X1);  drag has left the source window since TrackDrag 
  51. (defconstant $dragInsideSenderApplication #X2);  drag is occurring within the source application 
  52. (defconstant $dragInsideSenderWindow #X4);  drag is occurring within the source window 
  53.  
  54. (def-mactype :DRAGATTRIBUTES (find-mactype :SIGNED-LONG))
  55.  
  56. ;  Special Flavor Types 
  57.  
  58. (defconstant $flavorTypeHFS :|hfs |);  flavor type for HFS data 
  59. (defconstant $flavorTypePromiseHFS :|phfs|);  flavor type for promised HFS data 
  60. (defconstant $flavorTypeDirectory :|diry|);  flavor type for AOCE directory 
  61.  
  62. ;  Drag Tracking Handler Messages 
  63.  
  64. (defconstant $dragTrackingEnterHandler 1);  drag has entered handler 
  65. (defconstant $dragTrackingEnterWindow 2);  drag has entered window 
  66. (defconstant $dragTrackingInWindow 3);  drag is moving within window 
  67. (defconstant $dragTrackingLeaveWindow 4);  drag has exited window 
  68. (defconstant $dragTrackingLeaveHandler 5);  drag has exited handler 
  69.  
  70. (def-mactype :DRAGTRACKINGMESSAGE (find-mactype :SIGNED-INTEGER))
  71.  
  72. ;  Drag Drawing Procedure Messages 
  73.  
  74. (defconstant $dragRegionBegin 1);  initialize drawing 
  75. (defconstant $dragRegionDraw 2) ;  draw drag feedback 
  76. (defconstant $dragRegionHide 3) ;  hide drag feedback 
  77. (defconstant $dragRegionIdle 4) ;  drag feedback idle time 
  78. (defconstant $dragRegionEnd 5)  ;  end of drawing 
  79.  
  80. (def-mactype :DRAGREGIONMESSAGE (find-mactype :SIGNED-INTEGER))
  81.  
  82. ;  Zoom Acceleration 
  83.  
  84. (defconstant $zoomNoAcceleration 0);  use linear interpolation 
  85. (defconstant $zoomAccelerate 1) ;  ramp up step size 
  86. (defconstant $zoomDecelerate 2) ;  ramp down step size 
  87.  
  88. (def-mactype :ZOOMACCELERATION (find-mactype :SIGNED-INTEGER))
  89.  
  90. ;  Drag Manager Data Types 
  91.  
  92. (def-mactype :DRAGREFERENCE (find-mactype :SIGNED-LONG))
  93. (def-mactype :ITEMREFERENCE (find-mactype :SIGNED-LONG))
  94.  
  95. (def-mactype :FLAVORTYPE (find-mactype :OSTYPE))
  96.  
  97. ;  Result Codes - (will move to Errors.p) 
  98.  
  99. (defconstant $badDragRefErr -1850);  unknown drag reference 
  100. (defconstant $badDragItemErr -1851);  unknown drag item reference 
  101. (defconstant $badDragFlavorErr -1852);  unknown flavor type 
  102. (defconstant $duplicateFlavorErr -1853);  flavor type already exists 
  103. (defconstant $cantGetFlavorErr -1854);  error while trying to get flavor data 
  104. (defconstant $duplicateHandlerErr -1855);  handler already exists 
  105. (defconstant $handlerNotFoundErr -1856);  handler not found 
  106. (defconstant $dragNotAcceptedErr -1857);  drag was not accepted by receiver 
  107.  
  108. ;  HFS Flavor 
  109.  
  110. (defrecord HFSFlavor 
  111.    (fileType :OSTYPE)           ;  file type 
  112.    (fileCreator :OSTYPE)        ;  file creator 
  113.    (fdFlags :SIGNED-INTEGER)    ;  Finder flags 
  114.    (fileSpec :FSSPEC)           ;  file system specification 
  115.    )
  116.  
  117. ;  Promise HFS Flavor 
  118.  
  119. (defrecord PromiseHFSFlavor 
  120.    (fileType :OSTYPE)           ;  file type 
  121.    (fileCreator :OSTYPE)        ;  file creator 
  122.    (fdFlags :SIGNED-INTEGER)    ;  Finder flags 
  123.    (promisedFlavor :OSTYPE)     ;  promised flavor containing FSSpec 
  124.    )
  125.  
  126. ;  Application-Defined Drag Handler Routines 
  127.  
  128. (def-mactype :DRAGTRACKINGHANDLER (find-mactype :POINTER));  FUNCTION TrackingHandler    (message : DragTrackingMessage,
  129. ;                                                                              theWindow : WindowPtr,
  130. ;                                                                               handlerRefCon : Ptr,
  131. ;                                                                              theDragRef : DragReference) : OSErr; 
  132. (def-mactype :DRAGRECEIVEHANDLER (find-mactype :POINTER));  FUNCTION ReceiveHandler    (theWindow : WindowPtr,
  133. ;                                                                              handlerRefCon : Ptr,
  134. ;                                                                              theDragRef : DragReference) : OSErr; 
  135.  
  136. ;  Application-Defined Routines 
  137.  
  138. (def-mactype :DRAGSENDDATAPROC (find-mactype :POINTER));  FUNCTION SendDataProc        (theType : FlavorType,
  139. ;                                                                              dragSendRefCon : Ptr,
  140. ;                                                                              theItemRef : ItemReference,
  141. ;                                                                              theDragRef : DragReference) : OSErr; 
  142. (def-mactype :DRAGINPUTPROC (find-mactype :POINTER));  FUNCTION InputProc        (VAR mouse : Point,
  143. ;                                                                              VAR modifiers : INTEGER,
  144. ;                                                                              dragInputRefCon : Ptr,
  145. ;                                                                              theDragRef : DragReference) : OSErr; 
  146. (def-mactype :DRAGDRAWINGPROC (find-mactype :POINTER));  FUNCTION DrawingProc        (message : DragRegionMessage,
  147. ;                                                                              showRegion : RgnHandle,
  148. ;                                                                              showOrigin : Point,
  149. ;                                                                              hideRegion : RgnHandle,
  150. ;                                                                              hideOrigin : Point,
  151. ;                                                                              dragDrawingRefCon : Ptr,
  152. ;                                                                              theDragRef : DragReference) : OSErr; 
  153.  
  154. ;  Drag Manager Routines 
  155.  
  156. ;  Installing and Removing Drag Handlers 
  157.  
  158.  
  159. (deftrap _installtrackinghandler ((trackinghandler :pointer) (thewindow :windowptr) (handlerrefcon :pointer))
  160.    (:stack :signed-integer)
  161.    (:stack-trap #xABED :d0 1 trackinghandler thewindow handlerrefcon))
  162.  
  163.  
  164. (deftrap _installreceivehandler ((receivehandler :pointer) (thewindow :windowptr) (handlerrefcon :pointer))
  165.    (:stack :signed-integer)
  166.    (:stack-trap #xABED :d0 2 receivehandler thewindow handlerrefcon))
  167.  
  168.  
  169. (deftrap _removetrackinghandler ((trackinghandler :pointer) (thewindow :windowptr))
  170.    (:stack :signed-integer)
  171.    (:stack-trap #xABED :d0 3 trackinghandler thewindow))
  172.  
  173.  
  174. (deftrap _removereceivehandler ((receivehandler :pointer) (thewindow :windowptr))
  175.    (:stack :signed-integer)
  176.    (:stack-trap #xABED :d0 4 receivehandler thewindow))
  177.  
  178. ;  Creating and Disposing Drag References 
  179.  
  180.  
  181. (deftrap _newdrag ((thedragref (:pointer :signed-long)))
  182.    (:stack :signed-integer)
  183.    (:stack-trap #xABED :d0 5 thedragref))
  184.  
  185.  
  186. (deftrap _disposedrag ((thedragref :signed-long))
  187.    (:stack :signed-integer)
  188.    (:stack-trap #xABED :d0 6 thedragref))
  189.  
  190. ;  Adding Drag Item Flavors 
  191.  
  192.  
  193. (deftrap _adddragitemflavor ((thedragref :signed-long) (theitemref :signed-long) (thetype :ostype) (dataptr :pointer) (datasize :size) (theflags :signed-long))
  194.    (:stack :signed-integer)
  195.    (:stack-trap #xABED :d0 7 thedragref theitemref thetype dataptr datasize theflags))
  196.  
  197.  
  198. (deftrap _addhfsflavor ((thedragref :signed-long) (theitemref :signed-long) (filespec :fsspec) (theflags :signed-long))
  199.    (:stack :signed-integer)
  200.    (:stack-trap #xABED :d0 8 thedragref theitemref filespec theflags))
  201.  
  202.  
  203. (deftrap _setdragitemflavordata ((thedragref :signed-long) (theitemref :signed-long) (thetype :ostype) (dataptr :pointer) (datasize :size) (dataoffset :signed-long))
  204.    (:stack :signed-integer)
  205.    (:stack-trap #xABED :d0 9 thedragref theitemref thetype dataptr datasize dataoffset))
  206.  
  207. ;  Providing Drag Callback Procedures 
  208.  
  209.  
  210. (deftrap _setdragsendproc ((thedragref :signed-long) (sendproc :pointer) (dragsendrefcon :pointer))
  211.    (:stack :signed-integer)
  212.    (:stack-trap #xABED :d0 10 thedragref sendproc dragsendrefcon))
  213.  
  214.  
  215. (deftrap _setdraginputproc ((thedragref :signed-long) (inputproc :pointer) (draginputrefcon :pointer))
  216.    (:stack :signed-integer)
  217.    (:stack-trap #xABED :d0 11 thedragref inputproc draginputrefcon))
  218.  
  219.  
  220. (deftrap _setdragdrawingproc ((thedragref :signed-long) (drawingproc :pointer) (dragdrawingrefcon :pointer))
  221.    (:stack :signed-integer)
  222.    (:stack-trap #xABED :d0 12 thedragref drawingproc dragdrawingrefcon))
  223.  
  224. ;  Performing a Drag 
  225.  
  226.  
  227. (deftrap _trackdrag ((thedragref :signed-long) (theevent :eventrecord) (theregion :rgnhandle))
  228.    (:stack :signed-integer)
  229.    (:stack-trap #xABED :d0 13 thedragref theevent theregion))
  230.  
  231. ;  Getting Drag Item Information 
  232.  
  233.  
  234. (deftrap _countdragitems ((thedragref :signed-long) (numitems (:pointer :signed-integer)))
  235.    (:stack :signed-integer)
  236.    (:stack-trap #xABED :d0 14 thedragref numitems))
  237.  
  238.  
  239. (deftrap _getdragitemreferencenumber ((thedragref :signed-long) (index :signed-integer) (theitemref (:pointer :signed-long)))
  240.    (:stack :signed-integer)
  241.    (:stack-trap #xABED :d0 15 thedragref index theitemref))
  242.  
  243.  
  244. (deftrap _countdragitemflavors ((thedragref :signed-long) (theitemref :signed-long) (numflavors (:pointer :signed-integer)))
  245.    (:stack :signed-integer)
  246.    (:stack-trap #xABED :d0 16 thedragref theitemref numflavors))
  247.  
  248.  
  249. (deftrap _getflavortype ((thedragref :signed-long) (theitemref :signed-long) (index :signed-integer) (thetype (:pointer :ostype)))
  250.    (:stack :signed-integer)
  251.    (:stack-trap #xABED :d0 17 thedragref theitemref index thetype))
  252.  
  253.  
  254. (deftrap _getflavorflags ((thedragref :signed-long) (theitemref :signed-long) (thetype :ostype) (theflags (:pointer :signed-long)))
  255.    (:stack :signed-integer)
  256.    (:stack-trap #xABED :d0 18 thedragref theitemref thetype theflags))
  257.  
  258.  
  259. (deftrap _getflavordatasize ((thedragref :signed-long) (theitemref :signed-long) (thetype :ostype) (datasize (:pointer :size)))
  260.    (:stack :signed-integer)
  261.    (:stack-trap #xABED :d0 19 thedragref theitemref thetype datasize))
  262.  
  263.  
  264. (deftrap _getflavordata ((thedragref :signed-long) (theitemref :signed-long) (thetype :ostype) (dataptr :pointer) (datasize (:pointer :size)) (dataoffset :signed-long))
  265.    (:stack :signed-integer)
  266.    (:stack-trap #xABED :d0 20 thedragref theitemref thetype dataptr datasize dataoffset))
  267.  
  268.  
  269. (deftrap _getdragitembounds ((thedragref :signed-long) (theitemref :signed-long) (itembounds (:pointer :rect)))
  270.    (:stack :signed-integer)
  271.    (:stack-trap #xABED :d0 21 thedragref theitemref itembounds))
  272.  
  273.  
  274. (deftrap _setdragitembounds ((thedragref :signed-long) (theitemref :signed-long) (itembounds :rect))
  275.    (:stack :signed-integer)
  276.    (:stack-trap #xABED :d0 22 thedragref theitemref itembounds))
  277.  
  278.  
  279. (deftrap _getdroplocation ((thedragref :signed-long) (droplocation (:pointer :aedesc)))
  280.    (:stack :signed-integer)
  281.    (:stack-trap #xABED :d0 23 thedragref droplocation))
  282.  
  283.  
  284. (deftrap _setdroplocation ((thedragref :signed-long) (droplocation :aedesc))
  285.    (:stack :signed-integer)
  286.    (:stack-trap #xABED :d0 24 thedragref droplocation))
  287.  
  288. ;  Getting Information About a Drag 
  289.  
  290.  
  291. (deftrap _getdragattributes ((thedragref :signed-long) (flags (:pointer :signed-long)))
  292.    (:stack :signed-integer)
  293.    (:stack-trap #xABED :d0 25 thedragref flags))
  294.  
  295.  
  296. (deftrap _getdragmouse ((thedragref :signed-long) (mouse (:pointer :point)) (pinnedmouse (:pointer :point)))
  297.    (:stack :signed-integer)
  298.    (:stack-trap #xABED :d0 26 thedragref mouse pinnedmouse))
  299.  
  300.  
  301. (deftrap _setdragmouse ((thedragref :signed-long) (pinnedmouse :point))
  302.    (:stack :signed-integer)
  303.    (:stack-trap #xABED :d0 27 thedragref pinnedmouse))
  304.  
  305.  
  306. (deftrap _getdragorigin ((thedragref :signed-long) (initialmouse (:pointer :point)))
  307.    (:stack :signed-integer)
  308.    (:stack-trap #xABED :d0 28 thedragref initialmouse))
  309.  
  310.  
  311. (deftrap _getdragmodifiers ((thedragref :signed-long) (modifiers (:pointer :signed-integer)) (mousedownmodifiers (:pointer :signed-integer)) (mouseupmodifiers (:pointer :signed-integer)))
  312.    (:stack :signed-integer)
  313.    (:stack-trap #xABED :d0 29 thedragref modifiers mousedownmodifiers mouseupmodifiers))
  314.  
  315. ;  Drag Highlighting 
  316.  
  317.  
  318. (deftrap _showdraghilite ((thedragref :signed-long) (hiliteframe :rgnhandle) (inside :boolean))
  319.    (:stack :signed-integer)
  320.    (:stack-trap #xABED :d0 30 thedragref hiliteframe inside))
  321.  
  322.  
  323. (deftrap _hidedraghilite ((thedragref :signed-long))
  324.    (:stack :signed-integer)
  325.    (:stack-trap #xABED :d0 31 thedragref))
  326.  
  327.  
  328. (deftrap _dragprescroll ((thedragref :signed-long) (dh :signed-integer) (dv :signed-integer))
  329.    (:stack :signed-integer)
  330.    (:stack-trap #xABED :d0 32 thedragref dh dv))
  331.  
  332.  
  333. (deftrap _dragpostscroll ((thedragref :signed-long))
  334.    (:stack :signed-integer)
  335.    (:stack-trap #xABED :d0 33 thedragref))
  336.  
  337.  
  338. (deftrap _updatedraghilite ((thedragref :signed-long) (updatergn :rgnhandle))
  339.    (:stack :signed-integer)
  340.    (:stack-trap #xABED :d0 34 thedragref updatergn))
  341.  
  342. ;  Drag Manager Utilities 
  343.  
  344.  
  345. (deftrap _waitmousemoved ((initialmouse :point))
  346.    (:stack :boolean)
  347.    (:stack-trap #xABED :d0 35 initialmouse))
  348.  
  349.  
  350. (deftrap _zoomrects ((fromrect :rect) (torect :rect) (zoomsteps :signed-integer) (acceleration :signed-integer))
  351.    (:stack :signed-integer)
  352.    (:stack-trap #xABED :d0 36 fromrect torect zoomsteps acceleration))
  353.  
  354.  
  355. (deftrap _zoomregion ((region :rgnhandle) (zoomdistance :point) (zoomsteps :signed-integer) (acceleration :signed-integer))
  356.    (:stack :signed-integer)
  357.    (:stack-trap #xABED :d0 37 region zoomdistance zoomsteps acceleration))
  358.  
  359. ;  Will move to TextEdit.p 
  360.  
  361. (deftrap _tegethilitergn ((region :rgnhandle) (hte :tehandle))
  362.    (:stack :signed-integer)
  363.    (:stack-trap #xA83D region hte (15 :signed-integer)))
  364.  
  365. ; $ENDC                         ;  UsingDrag 
  366.  
  367. ; $IFC NOT UsingIncludes
  368.  
  369. ; $ENDC
  370.  
  371. (export '($DRAGNOTACCEPTEDERR $HANDLERNOTFOUNDERR $DUPLICATEHANDLERERR
  372.           $CANTGETFLAVORERR $DUPLICATEFLAVORERR $BADDRAGFLAVORERR
  373.           $BADDRAGITEMERR $BADDRAGREFERR $ZOOMDECELERATE $ZOOMACCELERATE
  374.           $ZOOMNOACCELERATION $DRAGREGIONEND $DRAGREGIONIDLE $DRAGREGIONHIDE
  375.           $DRAGREGIONDRAW $DRAGREGIONBEGIN $DRAGTRACKINGLEAVEHANDLER
  376.           $DRAGTRACKINGLEAVEWINDOW $DRAGTRACKINGINWINDOW
  377.           $DRAGTRACKINGENTERWINDOW $DRAGTRACKINGENTERHANDLER
  378.           $FLAVORTYPEDIRECTORY $FLAVORTYPEPROMISEHFS $FLAVORTYPEHFS
  379.           $DRAGINSIDESENDERWINDOW $DRAGINSIDESENDERAPPLICATION
  380.           $DRAGHASLEFTSENDERWINDOW $FLAVORSYSTEMTRANSLATED $FLAVORNOTSAVED
  381.           $FLAVORSENDERTRANSLATED $FLAVORSENDERONLY $GESTALTTEHASGETHILITERGN
  382.           $GESTALTTEATTR $GESTALTDRAGMGRPRESENT $GESTALTDRAGMGRATTR))
  383. (provide-interface 'Drag)